/************************************************
 * Author       :   XXY
 * Blog         :   https://www.cnblogs.com/jzyl
 * Gitee        :   https://gitee.com/xiaobaichong
 * Email        :   1047185209@QQ.com
 * FileName     :   MainSystem.cs
 * CreateData   :   2023/7/11 22:31:32
 * UnityVersion :   2021.3.20f1c1
 * Description  :   主实体行为
************************************************/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Main;
using Main.Framework;
using Cysharp.Threading.Tasks;

namespace Hotfix
{
    /// <summary>
    /// <para>系统即为行为</para>
    /// <para>主实体行为</para>
    /// </summary>
    internal class MainSystem : SystemBase
    {
        MainComponent mainData;
        SecondComponent secondData;
        public override void Awake()
        {
            mainData = Entity.GetComponent<MainComponent>();
            secondData = Entity.GetComponent<SecondComponent>();
        }
        public override void Start()
        {
            Debug.Log(mainData.Ricer);
        }
        public override void Update()
        {
            if (Input.GetKeyDown(KeyCode.W))
            {
                ConfigFrameworkHelper.Get<MessageBoxCanvas>(nameof(MessageBoxCanvas)).Show(secondData.title, secondData.msg);
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                ConfigFrameworkHelper.Get<MessageNoticeCanvas>(nameof(MessageNoticeCanvas)).AddMsg("Hello World!");
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                ConfigFrameworkHelper.Get<MessagePageCanvas>(nameof(MessagePageCanvas)).Show();
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                _ = TestConfigData();
            }
        }
        private async UniTaskVoid TestConfigData()
        {
            TextConfig config = await ConfigDataHelper.Get<TextConfig>();
            Debug.Log(config["20001"]);
        }
    }
}